unit uUserLoginForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uAbstractForm, XPMan, StdCtrls, Buttons;

type
  TUserLoginForm = class(TAbstractForm)
    edtUserLogin: TEdit;
    edtPassword: TEdit;
    btnOk: TBitBtn;
    btnCancel: TBitBtn;
    lblUserLogin: TLabel;
    lblPassword: TLabel;
    procedure edtUserLoginChange(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  UserLogin: TUserLoginForm;

implementation
uses uUserControl;
{$R *.dfm}


procedure TUserLoginForm.edtUserLoginChange(Sender: TObject);
begin
  inherited;
  btnOk.Enabled:=(edtUserLogin.Text<>'')and(edtPassword.Text<>'');
end;

procedure TUserLoginForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  inherited;
  if ModalResult=1 then
  begin
    if not TUserControl.GetInstance.ValidateUserLogin(edtUserLogin.Text,
      edtPassword.Text) then
      begin
        MessageDlg('Invalid user/password!',mtWarning,[mbOk],0);
        CanClose:=false;
      end
      else
        TUserControl.GetInstance.AuthorizationLog;
  end;

end;

end.
